package com.itheim.array;
/*
 ATM机取款
 */

import java.util.Scanner;

public class ArrayDemo11 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int password = 0;
        int amount = 0;
        int count = 0;
        while (true) {
            // 提示用户输入密码
            System.out.println("请您输入密码:");
            password = sc.nextInt();
            if (password != 111111) {
                count++;
                if (count == 3) {
                    System.out.println("密码错误,请取卡.");
                    break;
                }
                System.out.println("密码错误,请重新输入!");
            } else {
              lo:  while (true) {
                    System.out.println("请输入取款金额:");
                    amount = sc.nextInt();
                    if (amount < 0 || amount > 1000) {
                        System.out.println("您输入的金额有误,请重新输入!");
                    } else {
                        System.out.println("请取走现金:" + amount);
                        System.out.println("交易完成,请取卡.");
                        break lo;
                    }
                }
              break;
            }
        }
    }
}
